<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <script type="text/javascript" src="../js/jquery-1.12.4.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/jquery.bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.form.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.twbsPagination.min.js"></script>
    <script type="text/javascript">
        function toPage(page) {
            $("#myfrom").attr("action", "bidRequestSelect?currPage=" + page);
            $("#myfrom").submit();
        }


        $(function () {

            //拿到当前页
            var currPage = ${pager.currPage};
            //拿到最后一页
            var totalPages = ${pager.totalPages};

            if (currPage <= 1) {
                $("#prev").removeAttr("href");
            }

            if (currPage >= totalPages) {
                $("#next").removeAttr("href");
            }

            $(".btn_audit").click(function(){
                var form=$("#editform");
                form.find("[name=bidRequestState]").val($(this).val());
                $("#myModal").modal("hide");

                form.ajaxSubmit(function(data){

                    if(data.success){
                        $.messager.confirm("提示",data.msg,function(){
                            window.location.reload(true);
                        });
                    }else{
                        $.messager.confirm("提示","系统故障，操作失败");
                    }
                });
                return false;
            });

            $(".auditClass").click(function () {
                var json = $(this).data('json');
                $("#bidRequestId").val(json.bidRequestId);
                $("#title").html(json.title);
                $("#applierName").html(json.applier);
                $("#bidRequestAmount").html(json.bidRequestAmount);
                $("#monthes2Return").html(json.monthes2Return);
                $("#currentRate").html(json.currentRate);
                $("#totalRewardAmount").html(json.totalRewardAmount);
                $('#myModal').modal("show");
            })

        });

        f


    </script>

</head>

<body>
<div style="width: 200px; float: left;margin-left: 150px;margin-top: 100px"    >
    <li class="list-group-item" >
        <a href="#" data-toggle="collapse" data-target="#auditmanage_detail">
            <span>审核项目</span>
        </a>
        <ul class="in" id="auditmanage_detail">
            <li class="realAuth">
                <a href="./realAuthselect">实名认证审核</a>
            </li>
            <li class="vedioAuth">
                <a href="./vedioAuthselect">视频认证审核</a>
            </li>
            <li class="userFileAuth">
                <a href="./userFileselect">认证材料审核</a>
            </li>
            <li class="bidrequest_publishaudit_list">
                <a href="./bidRequestSelect">发标前审核</a>
            </li>
            <li class="bidrequest_audit1_list">
                <a href="./bidRequestSelect1">满标一审</a>
            </li>
            <li class="bidrequest_audit2_list">
                <a href="./bidRequestSelect2">满标二审</a>
            </li>
        </ul>
    </li>
</div>
<div style="width: 1000px; float: left;margin-top: 50px;margin-left: 50px">
<center>
    <h1>满标二审管理</h1>
</center>
<form id="myfrom" action="./bidRequestSelect2" method="post">

    <table align="center" width="70%" border="1px" class="table">
        <tr align="center">
            <td>标题</td>
            <td>借款人</td>
            <td>发标时间</td>
            <td>借款金额</td>
            <td>期限</td>
            <td>利率</td>
            <td>总利息</td>
            <td>状态</td>
        </tr>
        <c:forEach items="${list}" var="b" varStatus="st">
            <tr align="center"
                    <c:if test="${st.index %2 ==0 }">
                        style="background-color:gray"
                    </c:if>
            >
                <input type="hidden" name="bidRequestId" value="${b.bidRequestId}">
                <td>${b.title }</td>
                <td>${b.createUser.userName }</td>
                <td><fmt:formatDate value="${b.applyTime }" pattern="yyyy-MM-dd"/></td>
                <td>${b.bidRequestAmount }</td>
                <td>${b.monthes2Return }</td>
                <td>${b.currentRate }%</td>
                <td>${b.totalRewardAmount }</td>
                <td>
                    <c:if test="${b.bidRequestState== 4 }">满标二审</c:if>
                </td>
                <td>
                    <c:if test="${ b.bidRequestState== 4 }">
                        <a class="auditClass"
                           data-json='{"title":"${b.title}","applier":"${b.createUser.userName}"
                                ,"bidRequestAmount":"${b.bidRequestAmount}"
                                ,"monthes2Return":"${b.monthes2Return}","currentRate":"${b.currentRate}"
                                ,"totalRewardAmount":"${b.totalRewardAmount}","bidRequestId":"${b.bidRequestId}" }'>
                            <button id="btn_add" type="button" class="btn btn-primary">审核</button>
                        </a>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
    </table>

    <center>
        <a href="javaScript:toPage(1)">首页</a>&nbsp;&nbsp;
        <a id="prev" href="javaScript:toPage(${pager.currPage-1 })">上一页</a>&nbsp;&nbsp;
        <a id="next" href="javaScript:toPage(${pager.currPage+1 })">下一页</a>&nbsp;&nbsp;
        <a href="javaScript:toPage(${pager.totalPages})">尾页</a>&nbsp;&nbsp;
        <span>第${pager.currPage }页/共${pager.totalPages }页</span>
    </center>
</form>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <form class="form-horizontal" id="editform" method="post" action="./bidRequestUpdate">
                        <fieldset>
                            <div id="legend" class="">
                                <legend>发标前认证审核</legend>
                            </div>
                            <input type="hidden" name="bidRequestId" id="bidRequestId" value="">
                            <input type="hidden" name="bidRequestState" id="bidRequestState" value="">
                            <div class="row">
                                <label class="col-sm-3 control-label" >标题</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="title" id="title"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >借款人</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="applierName" id="applierName"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >借款金额(元)</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="bidRequestAmount" id="bidRequestAmount"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >期限</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="monthes2Return" id="monthes2Return"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >利率</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="currentRate" id="currentRate"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >总利息</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="totalRewardAmount" id="totalRewardAmount"></label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" >审核备注</label>
                                <div class="col-sm-6">
                                    <textarea name="note" rows="7" cols="60"></textarea>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-success btn_audit" value="5">审核通过</button>
                    <button type="button" class="btn btn-warning btn_audit" value="6">审核拒绝</button>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
</html>
